package h0826;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 括号生成
 * @date 2024/8/26 0:05
 */
public class MakeBracket {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> res = buildBrackets(n);
        System.out.println(res);
    }

    private static List<String> buildBrackets(int n) {
        List<String> res=new ArrayList<>();
        backTrack(res,0,0,"",n);
        return res;
    }

    private static void backTrack(List<String> res, int left, int right, String s, int n) {
        if (s.length()==2*n){
            res.add(s);
        }
        if (left<n){
            backTrack(res,left+1,right,s+"(",n);
        }
        if (right<left){
            backTrack(res,left,right+1,s+")",n);
        }
    }
}
